﻿@{
    ViewBag.Title = "MemberTag";
}

@section scripts
{
    <script src="@Url.Content("~/Scripts/shared/share.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/shared/shown.js")" type="text/javascript"></script>
}
@Html.Partial("~/Views/Modular/ToolBarBaseEx.cshtml")
@Html.Partial("~/Views/Modular/SearchInfo.cshtml")
<div class="mini-fit">
    <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" pageSize="15"
         borderStyle="border:1;" url="GetTagList"
         allowCellSelect="true" allowCellEdit="true" showColumnsMenu="true" fitColumns="false"
         onrowdblclick="modify" sortMode="client">
        <div property="columns">
            <div type="checkcolumn">选行</div>
            <div type="indexcolumn" width="40" headerAlign="center">序号</div>
            <div field="FName" name="FName" width="200" headeralign="center" allowsort="true">标签名</div>
            <div field="FRemark" name="FRemark" width="300" headeralign="center" allowsort="true">备注</div>
        </div>
    </div>
</div>

<script>
    function FormShown() {
        mini.parse();
        LoadListData();
    }

    function setkeyPress() {
        LoadListData();
    }

    //加载资料列表
    function LoadListData() {
        var sSystemAppID = parent.window.getSystemAppID();
        var json = "[{";
        json = json + "'FSystemAppID':" + "'" + sSystemAppID + "',";
        json = json + "'search':" + "'" + mini.getbyName("FSearchKey").getValue() + "'";
        json = json + "}]";
        var grid = mini.get("datagrid1");//==
        grid.load({ mjson: json });
    }

    //搜索资料列表
    function search() {
        LoadListData();
    }

    //刷新
    function refresh() {
        mini.getbyName("FSearchKey").setValue('');
        LoadListData();
    }

    ///增加资料
    function newBill() {
        var uID = parent.window.getSystemAppID();
        mini.open({
            url: "/Member/MemberTagInfo",
            title: "会员标签", width: 420, height: 220,
            onload: function () {
                var iframe = this.getIFrameEl();
                var data = { action: "new", FItemID: "0" };
                iframe.contentWindow.SetInfoData(data);
            },
            ondestroy: function (action) {
                var grid = mini.get("datagrid1");
                grid.reload();
            }
        });
    }

    //修改资料
    function modify() {
        if (!mini.get("edit").getVisible()) return;
        var grid = mini.get("datagrid1");
        var row = grid.getSelected();
        if (row) {
            mini.open({
                url: "/Member/MemberTagInfo",
                title: "会员标签", width: 420, height: 220,
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var data = { action: "edit", FItemID: row.FItemID };
                    iframe.contentWindow.SetInfoData(data);
                },
                ondestroy: function (action) {
                    var grid = mini.get("datagrid1");
                    grid.reload();
                }
            });

        } else {
            mini.alert("请选中一条记录");
        }
    }

    //删除资料
    function removeInfo() {
        var grid = mini.get("datagrid1");
        var row = grid.getSelected();
        var FSystemAppID = parent.window.getSystemAppID();
        if (row) {
            mini.confirm("确定删除选中记录？", "提示",
            function (action) {
                if (action == "ok") {

                    var json = "{'FItemID':'" + row.FItemID + "'}";
                    $.post("RemoveMemberTagInfo", { json: json, mSystemAppID: FSystemAppID }, function (data) {
                        var ret = mini.decode(data);
                        if (ret.status == 1) {
                            grid.reload();
                        }
                        else {
                            mini.alert("异常:" + ret.error);
                        }
                    });
                }
            });
        } else {
            mini.alert("请选中一条记录");
        }
    }

</script>